/*  */

var namespaceMap = {
    svg: 'http://www.w3.org/2000/svg',
    math: 'http://www.w3.org/1998/Math/MathML'
};

var isHTMLTag = makeMap(
    'html,body,base,head,link,meta,style,title,' +
    'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
    'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
    'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
    's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
    'embed,object,param,source,canvas,script,noscript,del,ins,' +
    'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
    'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
    'output,progress,select,textarea,' +
    'details,dialog,menu,menuitem,summary,' +
    'content,element,shadow,template,blockquote,iframe,tfoot'
);

// this map is intentionally selective, only covering SVG elements that may
// contain child elements.
var isSVG = makeMap(
    'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
    'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
    'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
    true
);

/*  */

var isUnaryTag = makeMap(
    'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
    'link,meta,param,source,track,wbr'
);

// Elements that you can, intentionally, leave open
// (and which close themselves)
var canBeLeftOpenTag = makeMap(
    'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
);

// HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
// Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
var isNonPhrasingTag = makeMap(
    'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
    'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
    'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
    'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
    'title,tr,track'
);

var isPreTag = function (tag) {
    return tag === 'pre';
};

var isReservedTag = function (tag) {
    return isHTMLTag(tag) || isSVG(tag)
};


function getTagNamespace(tag) {

    if (isSVG(tag)) {
        return 'svg'
    }

    // basic support for MathML
    // note it doesn't support other MathML elements being component roots
    if (tag === 'math') {
        return 'math'
    }
}

var unknownElementCache = Object.create(null);

function isUnknownElement(tag) {

    /* istanbul ignore if */
    if (!inBrowser) {
        return true
    }

    if (isReservedTag(tag)) {
        return false
    }

    tag = tag.toLowerCase();

    /* istanbul ignore if */
    if (unknownElementCache[tag] != null) {
        return unknownElementCache[tag]
    }

    var el = document.createElement(tag);

    if (tag.indexOf('-') > -1) {

        // http://stackoverflow.com/a/28210364/1070244
        return (unknownElementCache[tag] = (
            el.constructor === window.HTMLUnknownElement ||
            el.constructor === window.HTMLElement
        ))

    } else {
        return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
    }

}

var isTextInputType = makeMap('text,number,password,search,email,tel,url');



/*  */

/**
 * Query an element selector if it's not an element already.
 * g：查找节点
 */
function query(el) {

    if (typeof el === 'string') {

        var selected = document.querySelector(el);
        if (!selected) {
            "development" !== 'production' && warn(
                'Cannot find element: ' + el
            );
            return document.createElement('div')
        }

        return selected
    } else {
        return el
    }
}

/*  */

function createElement$1(tagName, vnode) {

    var elm = document.createElement(tagName);
    if (tagName !== 'select') return elm

    // false or null will remove the attribute but undefined will not
    if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
        elm.setAttribute('multiple', 'multiple');
    }

    return elm
}

// g：创建带有命名空间的元素节点，该方法返回 Element 对象。
function createElementNS(namespace, tagName) {
    return document.createElementNS(namespaceMap[namespace], tagName)
}

function createTextNode(text) {
    return document.createTextNode(text)
}

function createComment(text) {
    return document.createComment(text)
}

function insertBefore(parentNode, newNode, referenceNode) {
    parentNode.insertBefore(newNode, referenceNode);
}

function removeChild(node, child) {
    node.removeChild(child);
}

function appendChild(node, child) {
    node.appendChild(child);
}

function parentNode(node) {
    return node.parentNode
}

function nextSibling(node) {
    return node.nextSibling
}

function tagName(node) {
    return node.tagName
}

function setTextContent(node, text) {
    node.textContent = text;
}

function setStyleScope(node, scopeId) {
    node.setAttribute(scopeId, '');
}


var nodeOps = Object.freeze({
    createElement: createElement$1,
    createElementNS: createElementNS,
    createTextNode: createTextNode,
    createComment: createComment,
    insertBefore: insertBefore,
    removeChild: removeChild,
    appendChild: appendChild,
    parentNode: parentNode,
    nextSibling: nextSibling,
    tagName: tagName,
    setTextContent: setTextContent,
    setStyleScope: setStyleScope
});












/**
 * Add class with compatibility for SVG since classList is not supported on
 * SVG elements in IE
 */
function addClass(el, cls) {

    /* istanbul ignore if */
    if (!cls || !(cls = cls.trim())) {
        return
    }

    /* istanbul ignore else */
    if (el.classList) {

        if (cls.indexOf(' ') > -1) {
            cls.split(/\s+/).forEach(function (c) {
                return el.classList.add(c);
            });

        } else {
            el.classList.add(cls);
        }

    } else {

        var cur = " " + (el.getAttribute('class') || '') + " ";
        if (cur.indexOf(' ' + cls + ' ') < 0) {
            el.setAttribute('class', (cur + cls).trim());
        }
    }
}

/**
 * Remove class with compatibility for SVG since classList is not supported on
 * SVG elements in IE
 */
function removeClass(el, cls) {

    /* istanbul ignore if */
    if (!cls || !(cls = cls.trim())) {
        return
    }

    /* istanbul ignore else */
    if (el.classList) {

        if (cls.indexOf(' ') > -1) {
            cls.split(/\s+/).forEach(function (c) {
                return el.classList.remove(c);
            });
        } else {
            el.classList.remove(cls);
        }
        if (!el.classList.length) {
            el.removeAttribute('class');
        }

    } else {

        var cur = " " + (el.getAttribute('class') || '') + " ";
        var tar = ' ' + cls + ' ';

        while (cur.indexOf(tar) >= 0) {
            cur = cur.replace(tar, ' ');
        }

        cur = cur.trim();

        if (cur) {
            el.setAttribute('class', cur);
        } else {
            el.removeAttribute('class');
        }
    }
}